package com.itheima.Buffer.anli;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        try (
                FileReader fr = new FileReader("day14_IO\\src\\com\\itheima\\Buffer\\anli\\haiyan.txt");
                FileWriter fw = new FileWriter("day14_IO\\src\\com\\itheima\\Buffer\\anli\\haiyan1.txt");
                BufferedReader br = new BufferedReader(fr);
                BufferedWriter bw = new BufferedWriter(fw);
                ){
            //读取文件内容并存储到list集合中
            String len;
            while ((len =br.readLine() ) != null){
                list.add(len);
            }
            list.forEach(System.out::println);
            TreeSet<String> set = new TreeSet<>(list);
            for (String s : set) {
                bw.write(s);
                bw.newLine();
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
